package com.atguigu;

import java.util.Iterator;

/**
 * 计算机学院接口实现类 IteratorImpl
 *
 * @author melo
 */
public class ComputerCollegeIterator implements Iterator<Department> {

    /**
     * 这里我们需要知道Department是以怎样的方式存放 => 数组
     */
    Department[] departments;

    /**
     * 当前遍历的位置
     */
    int position = 0;

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    /**
     * 判断是否还有下一个元素
     *
     * @return 下一个元素
     */
    @Override
    public boolean hasNext() {
        return position < departments.length && departments[position] != null;
    }

    @Override
    public Department next() {
        Department department = departments[position];
        position ++;
        return department;
    }

    /**
     * 删除的方法，默认空实现
     */
    @Override
    public void remove() {

    }

}
